//
//  PlatformIntroductionTableViewCell.m
//  yonghu
//
//  Created by 浪尖渝力 on 2018/2/7.
//  Copyright © 2018年 com.DJS. All rights reserved.
//

#import "PlatformIntroductionTableViewCell.h"

@implementation PlatformIntroductionTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(float)creatView{
    self.backgroundColor=_LightGrey;
    
    
    UIView *beiJingView=[UIView new];
    [self addSubview:beiJingView];
    [beiJingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.top.mas_equalTo(10);
    }];
    beiJingView.backgroundColor=[UIColor whiteColor];
    
    UIView *xianView=[UIView new];
    [beiJingView addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.height.mas_equalTo(25);
        make.width.mas_equalTo(4);
        make.top.mas_equalTo(10);
    }];
    xianView.backgroundColor=_backgroundColor;
    
    UILabel *label=[UILabel new];
    [beiJingView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(xianView);
        make.left.mas_equalTo(xianView.mas_right).mas_equalTo(20);
    }];
    label.text=@"平台介绍";
    label.font=[UIFont systemFontOfSize:18];
    label.textColor=ColorWithRGB(29, 29, 29);
    
    UIImageView *iamgeView=[UIImageView new];
    [beiJingView addSubview:iamgeView];
    [iamgeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(xianView.mas_bottom).mas_equalTo(30);
        make.height.mas_equalTo(_mainW*0.35);
    }];
    iamgeView.image=[UIImage imageNamed:@"精选咨询背景图"];
    
    
    NSString *str=@"在中国食品产业分析师朱丹蓬看来，泸州老窖出产香水，标志着中国白酒行业普遍走向年轻化，希望吸引更多年轻消费者而进行的布局。朱丹蓬表示，在新生代成为消费主流之后，如何在未来与整个新生代消费群体加强连接和粘性，这是中国白酒企业以及其他许多企业面临的难题。无论是泸州老窖香水，还是其他品牌的一些青春小酒、低度酒以及其他一些年轻态的产品，都是为吸引新生代消费群体所做的布局。在中国食品产业分析师朱丹蓬看来，泸州老窖出产香水，标志着中国白酒行业普遍走向年轻化，希望吸引更多年轻消费者而进行的布局。朱丹蓬表示，在新生代成为消费主流之后，如何在未来与整个新生代消费群体加强连接和粘性，这是中国白酒企业以及其他许多企业面临的难题。无论是泸州老窖香水，还是其他品牌的一些青春小酒、低度酒以及其他一些年轻态的产品，都是为吸引新生代消费群体所做的布局";
    
    CGSize size=[ZQTools getNSStringSize:str andViewWight:_mainW-40 andFont:18];
    
    UILabel *contentLabel=[UILabel new];
    [beiJingView addSubview:contentLabel];
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(iamgeView.mas_bottom).mas_equalTo(20);
    }];
    contentLabel.numberOfLines=0;
    contentLabel.text=str;
    contentLabel.textColor=ColorWithRGB(149, 149, 149);
    contentLabel.font=[UIFont systemFontOfSize:18];
    
    CGFloat widht=110+_mainW*0.3;

    if (_num.integerValue==1) {
        if (size.height>150) {
            contentLabel.numberOfLines=6;
            UIImageView *imageView2=[UIImageView new];
            [beiJingView addSubview:imageView2];
            [imageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.mas_equalTo(0);
                make.bottom.mas_equalTo(-5);
                make.width.mas_equalTo(22);
                make.height.mas_equalTo(14);
            }];
            imageView2.tag=2;
            imageView2.image=[UIImage imageNamed:@"展开"];
            imageView2.userInteractionEnabled=YES;
            UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zhanKaiOrShouqi:)];
            [imageView2 addGestureRecognizer:tapGesture];
            widht=widht+170;
        }
        else{
            widht=widht+size.height;
        }
    }
    else{
        contentLabel.numberOfLines=0;
        if (size.height>150) {
            UIImageView *imageView2=[UIImageView new];
            [beiJingView addSubview:imageView2];
            [imageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.mas_equalTo(0);
                make.bottom.mas_equalTo(-5);
                make.width.mas_equalTo(22);
                make.height.mas_equalTo(14);
            }];
            imageView2.tag=1;
            imageView2.image=[UIImage imageNamed:@"收起"];
            imageView2.userInteractionEnabled=YES;
            UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(zhanKaiOrShouqi:)];
            [imageView2 addGestureRecognizer:tapGesture];

             widht=widht+size.height+30;
        }
        else{
             widht=widht+size.height;
        }

    }
    return widht;
}
-(void)creatView2{
    self.backgroundColor=_LightGrey;
    
    UIImageView *iamgeView=[UIImageView new];
    [self addSubview:iamgeView];
    [iamgeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(15);
        make.height.mas_equalTo(_mainW*0.35);
    }];
    iamgeView.image=[UIImage imageNamed:@"adbc-1"];
    
}
-(void)creatView3{
    self.backgroundColor=_LightGrey;
    
    UIImageView *iamgeView=[UIImageView new];
    [self addSubview:iamgeView];
    [iamgeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(15);
        make.height.mas_equalTo(_mainW*0.35);
    }];
    iamgeView.image=[UIImage imageNamed:@"专家背景"];
    
}
-(void)zhanKaiOrShouqi:(UITapGestureRecognizer *)tap{
    
    if (tap.view.tag==1) {
      _customSelectedBlock(@1);
    }else{
      _customSelectedBlock(@2);
    }
    
    
}

@end
